﻿using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Text;

public class ABScanWindows : EditorWindow
{
    public static ABScanWindows instance;
    [MenuItem("Tools/Show AssetBundle Builder")]
    public static void Open()
    {
        instance = (ABScanWindows)EditorWindow.GetWindow(typeof(ABScanWindows));
        instance.Init();
    }

    protected static string DATA_PATH = "/../abdata" + '/';
    public void Init()
    {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.Append("G:/Games/HoneySelectJY/HoneySelect_32_Data");
        stringBuilder.Append(DATA_PATH);
        global::AssetBundleManager.Initialize("abdata", stringBuilder.ToString());
        title = "Builder";
        minSize = new Vector2(300f, 400f);


    }

    public void OnGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();
        DrawLoadedInfoArea();
        GUILayout.EndVertical();
        GUILayout.BeginVertical();
        DrawLoadedAssetInfoArea();
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }

    public void DrawLoadedInfoArea()
    {
		GUILayout.BeginHorizontal();
        EditorGUILayout.TextField("Load Path", ABConfig.LoadPath);
        if (GUILayout.Button("Open"))
        {
            var path = EditorUtility.OpenFolderPanel("Load", ABConfig.LoadPath, "");
            ABConfig.LoadPath = string.IsNullOrEmpty(path) ? ABConfig.LoadPath : path;
        }
		GUILayout.EndHorizontal();

    }

    public void DrawLoadedAssetInfoArea()
    {

    }

    #region 操作
    public void LoadAB(string path)
    {
        AssetBundleManager.LoadAllAsset(path, typeof(object));
    }
    #endregion
}
